#! /bin/bash

# num1 op num2

num_usage() {
  printf "please input a num\n"
  exit 1
}

operator_usage() {
  printf "operator can only be (+ - * /)\n"
  exit 2
}

read -p "input num1:" num1
if [ -n "`echo $num1|sed 's/[0-9]//g'`" ]
  then
    num_usage
fi

read -p "input an oprator:" op
if [  "${op}" != "+"  ] && [  "${op}" != "-"  ] && [  "${op}" != "*"  ] && [  "${op}" != "/"  ]
  then
    operator_usage
fi

read -p "input num2:" num2
if [ -n "`echo $num2|sed 's/[0-9]//g'`" ]
  then
    num_usage
fi

printf "${num1} ${op} ${num2} = $((${num1}${op}${num2}))\n"
